package com.yupi.example.consumer;

import ch.qos.logback.core.util.TimeUtil;
import com.yupi.example.common.model.User;
import com.yupi.example.common.service.UserService;
import com.yupi.yurpc.proxy.ServiceProxyFactory;

import java.sql.Time;
import java.util.concurrent.TimeUnit;

public class EasyConsumerExample {
    public static void main(String[] args) {
        // todo需要获取 userService的实现对象
        // 静态代理
//        UserService userService = new UserServiceProxy();
        // 动态代理
        for (int i = 0; i < 10; i++) {
            System.out.println(i);
            UserService userService = ServiceProxyFactory.getProxy(UserService.class);
            User user = new User();
            user.setName("hy");
            // 调用服务
            User newUser = userService.getUser(user);
            if (newUser != null)
                System.out.println(newUser.getName());
            else
                System.out.println("user == null");

            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        }

    }
}
